home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 25 / CU Amiga Magazine's Super CD-ROM 25 (1998)(EMAP Images)(GB)(Track 1 of 2)[!][issue 1998-08].iso / CUCD / WWW / http / www.cu-amiga.co.uk / features / c-tutorial / Part-13.lzx / Part-13 / PatchLib / Developer.doc next >
Text File  |  1996-01-21  |  4KB  |  109 lines

  1. Developer docs:
  2.  
  3.  
  4. Patch.library provides a variety of types of patchcodes, depending
  5. on the need of an application.
  6.  
  7.  
  8.  
  9.  
  10. Different types of patchcodes:
  11.  
  12. Type A:
  13.     Your patchcode will be called as a subroutine BEFORE the original
  14.     function.
  15.  
  16.     A type A patchcode is specified by passing a value greater than
  17.     zero with PATT_Priroity during InstallPatchTags().
  18.  
  19.     Your patchcode will called with the same value as the original
  20.         function would be called. Your patchcode must set up (or keep)
  21.     the registers in a way that the original function can be called
  22.     immediately after your function exits.
  23.  
  24.     Type A could be used for the following purposes:
  25.         - counting the number of calls to a function
  26.         - Send out a message, when a function is used (snoopdos)
  27.         - ...
  28.  
  29.     Note: When programming in C have a look at PATT_UseXResult to
  30.     keep (In C d0-d1/a0-a1 are scratch registers) or modify registers.
  31.  
  32.  
  33. Type B:
  34.     Your patchcode will be called as a subroutine BEFORE the original
  35.     function AND it is your task to call the original function.
  36.  
  37.     A type B patchcode is specified by passing a value greater than
  38.     zero with PATT_Priroity AND PATT_Original during
  39.     InstallPatchTags().
  40.  
  41.     Your patchcode will called with the same value as the original
  42.         function would be called. Your patchcode must return the same
  43.         result as the original function would have.
  44.  
  45.     You MUST ALWAYS call the original function (at the address
  46.     provided by PATT_Original), even if skipping
  47.     the original function seems to work.
  48.     If you do not call the original function, patches with lower
  49.     priority will not be executed.
  50.  
  51.     Type B could be used for the following purposes:
  52.         - changing parameters for a function
  53.         - ...
  54.  
  55.     Note:
  56.         PATT_Original is new with V6 of patch.library.
  57.         This type can be used much like SetFunction().
  58.  
  59.     Warning:
  60.         Using PATT_Original right is tricky!
  61.         Your patchcode must be ready to be called any time,
  62.         even before InstallPatchTags() returns.
  63.         This implies that the memory pointer passed
  64.         with PATT_Original must be used within your
  65.                 patchcode to call the original function.
  66.         To get around this problem, you may specify
  67.         PATT_Disable, TRUE when installing your patchcode, which
  68.         makes sure, that your patchcode will not be called
  69.         until you call SetPatch( patch, PATT_Disable, FALSE, TAG_DONE);
  70.  
  71.  
  72. Type C:
  73.     Your patchcode will be called as a subroutine INSTEAD of the
  74.     original function.
  75.  
  76.     A type C patchcode is specified by passing zero with PATT_Priroity
  77.     during InstallPatchTags().
  78.  
  79.     Your patchcode will called with the same value as the original
  80.         function would be called. Your patchcode must return a result
  81.     as the original function would have.
  82.  
  83.     You can call the original function by using the FALLBACK
  84.     Assembler macro or by specifying Fallback with the PatchXResult
  85.     system.
  86.  
  87.     Type C could be used for the following purposes:
  88.         - Replacing certain OS-Functions by better ones
  89.           (e.g.: CpuBlit, CpuClear, drivers for graphiccards,
  90.           etc ...
  91.         - ...
  92.  
  93.  
  94. Type D:
  95.     Your patchcode will be called as a subroutine AFTER the
  96.     original function.
  97.  
  98.     A type D patchcode is specified by passing a value less than zero
  99.     with PATT_Priroity during InstallPatchTags().
  100.  
  101.     Your patchcode will called with the same returncode as the original
  102.         function would have returned. Your patchcode must return a result
  103.     as the original function would have.
  104.  
  105.     Type D could be used for the following purposes:
  106.         - counting the number of calls to a function
  107.         - Send out a message, when a function has failed
  108.         - ...
  109.